package com.cogwheel.framework.graphics;

import java.awt.Color;

import javax.media.opengl.GL2;

import com.cogwheel.framework.init.CPreferences;
import com.cogwheel.framework.util.CRectangle;

public class CDRectangle extends CSprite{
	public Color Color;
	public CDRectangle(CPreferences preferences, Color color, CRectangle dimensions) { super(preferences, null, dimensions); Color = color; }
	
	@Override
	public void CDraw(GL2 gl){
		gl.glLoadIdentity();
		CToOrtho();
		CDraw2D(gl);
	}
	
	@Override
	public void CDraw2D(GL2 gl){
		gl.glColor4f(Color.getRed(), Color.getGreen(), Color.getBlue(), Color.getAlpha());
		gl.glTranslatef(xa, ya, 1f);
		gl.glPushMatrix();
			gl.glRotatef(Rotation, 0f, 0f, 1f);
			gl.glBegin(GL2.GL_QUADS);
				gl.glTexCoord2f(0.0f, 1.0f); //Upper left
				gl.glVertex2f(-w, h);
		
				gl.glTexCoord2f(1.0f, 1.0f); //Upper right
				gl.glVertex2f(w, h);
		
				gl.glTexCoord2f(1.0f, 0.0f); //Bottom right
				gl.glVertex2f(w, -h);
		
				gl.glTexCoord2f(0.0f, 0.0f); //Bottom left
				gl.glVertex2f(-w, -h);
			gl.glEnd();
		gl.glPopMatrix();
		gl.glColor4f(255, 255, 255, 255);
	}

}
